//
//  ProgressView.m
//  04-重绘-下载进度
//
//  Created by J on 16/2/23.
//  Copyright © 2016年 J. All rights reserved.
//

#import "ProgressView.h"
@interface ProgressView()

@end
@implementation ProgressView



- (void)setProgress:(CGFloat)progress
{
    _progress = progress;
    
    
    // 重新绘制圆弧
    //    [self drawRect:self.bounds];
    
    // 重绘，系统会先创建与view相关联的上下文，然后再调用drawRect
    [self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect {
    // 创建杯赛尓曲线
    
    CGFloat radius = rect.size.width * 0.5;
    CGPoint center = CGPointMake(radius, radius);
    
    UIBezierPath* path = [UIBezierPath bezierPathWithArcCenter:center radius:radius-3 startAngle:-M_PI_2 endAngle:-M_PI_2+M_PI*2*_progress clockwise:YES];
    [[UIColor redColor]set];
    [path stroke];
    
    
    NSLog(@"%f",M_PI_2*2*_progress);
    
    
//    NSLog(@"%@",NSStringFromCGPoint(_p    rogressLabel.center));
    
}


@end
